package com.nulldev.util.graphics.renderIt.renderer.swing.smoothCanvas;

import com.nulldev.util.graphics.renderIt.api.renderItConstants;

public enum RenderMethod {
	PAINT, /* DEFAULT */
	REPAINT,
	REPAINT_WITHIN_SYNC,
	PAINT_ALL,
	UPDATE;

	public static RenderMethod fromRIT(final int renderMethod) {
		switch (renderMethod) {
			case renderItConstants.RIT_SWING_PANEL_PAINT:
				return PAINT;
			case renderItConstants.RIT_SWING_PANEL_PAINT_ALL:
				return PAINT_ALL;
			case renderItConstants.RIT_SWING_PANEL_REPAINT:
				return REPAINT;
			case renderItConstants.RIT_SWING_PANEL_REPAINT_WITHIN_SYNC:
				return REPAINT_WITHIN_SYNC;
			case renderItConstants.RIT_SWING_PANEL_UPDATE:
				return UPDATE;
			default:
				throw new UnsupportedOperationException("Unknown render method: " + renderMethod);
		}
	}

	public static int toRIT(final RenderMethod method) {
		switch (method) {
			case PAINT:
				return renderItConstants.RIT_SWING_PANEL_PAINT;
			case PAINT_ALL:
				return renderItConstants.RIT_SWING_PANEL_PAINT_ALL;
			case REPAINT:
				return renderItConstants.RIT_SWING_PANEL_REPAINT;
			case REPAINT_WITHIN_SYNC:
				return renderItConstants.RIT_SWING_PANEL_REPAINT_WITHIN_SYNC;
			case UPDATE:
				return renderItConstants.RIT_SWING_PANEL_UPDATE;
			default:
				throw new UnsupportedOperationException("Unknown render method: " + method);
		}
	}
}
